import quopri
from imaplib import IMAP4
def getCode():
    m = IMAP4("imap.126.com")
    m.login("bobo1993324_2", "")
    email_id = m.select()[1][0]
    # m.search(None, "FROM", "noreply@steampowered.com")
    # TODO find index
    c = m.fetch(email_id, '(BODY[TEXT])')
    d = quopri.decodestring(c[1][0][1]).decode('utf-8')
    # TODO extract verification code
    i = d.find("Code")
    code = d[i+6:i+11]
    print(code)
    return code
